@@ -8,9 +8,11 @@ import android.support.annotation.Nullable; |
||
8 | 8 |
import android.text.TextUtils; |
9 | 9 |
import android.view.Gravity; |
10 | 10 |
import android.view.View; |
11 |
+import android.widget.CompoundButton; |
|
11 | 12 |
import android.widget.RadioGroup; |
12 | 13 |
import android.widget.TextSwitcher; |
13 | 14 |
import android.widget.TextView; |
15 |
+import android.widget.ToggleButton; |
|
14 | 16 |
import android.widget.ViewSwitcher; |
15 | 17 |
|
16 | 18 |
import com.umeng.analytics.MobclickAgent; |
@@ -38,7 +40,7 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{ |
||
38 | 40 |
|
39 | 41 |
@BindView(R.id.tv_current_price) TextView currentPriceText; |
40 | 42 |
@BindView(R.id.rg_upload_settings) RadioGroup uploadDelayRadioGroup; |
41 |
- |
|
43 |
+ @BindView(R.id.toggle_upload_lock) ToggleButton uploadToggleBtn; |
|
42 | 44 |
private BriefsPresenter presenter; |
43 | 45 |
|
44 | 46 |
@Override |
@@ -76,6 +78,13 @@ public class BriefsActivity extends BaseActivity implements BriefsContract.View{ |
||
76 | 78 |
return myText; |
77 | 79 |
} |
78 | 80 |
}; |
81 |
+ uploadToggleBtn.setChecked(Preferences.getInstance().isUploadInMobile()); |
|
82 |
+ uploadToggleBtn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { |
|
83 |
+ @Override |
|
84 |
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
|
85 |
+ Preferences.getInstance().setUploadInMobile(isChecked); |
|
86 |
+ } |
|
87 |
+ }); |
|
79 | 88 |
orderMsgSwitch.setFactory(factory); |
80 | 89 |
systemMsgSwitch.setFactory(factory); |
81 | 90 |
presenter = new BriefsPresenter(this,this); |
@@ -49,14 +49,6 @@ public class Preferences { |
||
49 | 49 |
return mPrefs.getString("lensManId",BuildConfig.isJumpLogin?"Cwi7HSh":NullStr); |
50 | 50 |
} |
51 | 51 |
|
52 |
- public String getWXCode(){ |
|
53 |
- return mPrefs.getString("wxcode", NullStr); |
|
54 |
- } |
|
55 |
- |
|
56 |
- public void setWXCode(String wxCode){ |
|
57 |
- mPrefs.edit().putString("wxcode",wxCode).commit(); |
|
58 |
- } |
|
59 |
- |
|
60 | 52 |
|
61 | 53 |
public void setCameraLibVersion(int version){ |
62 | 54 |
mPrefs.edit().putInt("cameraLibVer",version).commit(); |
@@ -82,6 +74,14 @@ public class Preferences { |
||
82 | 74 |
return mPrefs.getInt("delay",10); |
83 | 75 |
} |
84 | 76 |
|
77 |
+ public boolean isUploadInMobile(){ |
|
78 |
+ return mPrefs.getBoolean("uploadInMobile",true); |
|
79 |
+ } |
|
80 |
+ |
|
81 |
+ public void setUploadInMobile(boolean uploadInMobile){ |
|
82 |
+ mPrefs.edit().putBoolean("uploadInMobile",uploadInMobile).commit(); |
|
83 |
+ } |
|
84 |
+ |
|
85 | 85 |
|
86 | 86 |
public void clearPrefs(){ |
87 | 87 |
mPrefs.edit().clear().commit(); |
@@ -13,6 +13,7 @@ import com.android.common.utils.NetworkUtil; |
||
13 | 13 |
|
14 | 14 |
import ai.pai.lensman.bean.PhotoBean; |
15 | 15 |
import ai.pai.lensman.db.DBService; |
16 |
+import ai.pai.lensman.db.Preferences; |
|
16 | 17 |
|
17 | 18 |
public class UploadService extends Service implements UploadTask.OnPhotoUploadListener,Handler.Callback{ |
18 | 19 |
|
@@ -49,6 +50,9 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi |
||
49 | 50 |
if(!NetworkUtil.isNetworkConnected(this)){ |
50 | 51 |
return; |
51 | 52 |
} |
53 |
+ if (NetworkUtil.isMobileConnected(this) && !Preferences.getInstance().isUploadInMobile()) { |
|
54 |
+ return; |
|
55 |
+ } |
|
52 | 56 |
if(currentPhoto!=null){ |
53 | 57 |
LogHelper.d(TAG,"当前有图片正在上传"+currentPhoto); |
54 | 58 |
return; |
@@ -0,0 +1,7 @@ |
||
1 |
+<?xml version="1.0" encoding="utf-8"?> |
|
2 |
+<selector xmlns:android="http://schemas.android.com/apk/res/android"> |
|
3 |
+ |
|
4 |
+ <item android:drawable="@drawable/toggle_btn_on" android:state_checked="true"/> |
|
5 |
+ <item android:drawable="@drawable/toggle_btn_off" android:state_checked="false"/> |
|
6 |
+ |
|
7 |
+</selector> |
@@ -360,6 +360,42 @@ |
||
360 | 360 |
android:text="@string/upload_slow"/> |
361 | 361 |
</RadioGroup> |
362 | 362 |
|
363 |
+ <View |
|
364 |
+ android:layout_width="match_parent" |
|
365 |
+ android:layout_height="1px" |
|
366 |
+ android:background="@color/text_hint_grey_color" /> |
|
367 |
+ |
|
368 |
+ <LinearLayout |
|
369 |
+ android:layout_width="match_parent" |
|
370 |
+ android:layout_height="32dp" |
|
371 |
+ android:orientation="horizontal"> |
|
372 |
+ |
|
373 |
+ <TextView |
|
374 |
+ android:layout_width="0dp" |
|
375 |
+ android:layout_weight="1" |
|
376 |
+ android:layout_height="wrap_content" |
|
377 |
+ android:layout_gravity="center_vertical|left" |
|
378 |
+ android:paddingLeft="10dp" |
|
379 |
+ android:text="@string/upload_in_mobile_network" |
|
380 |
+ android:textColor="@color/_7B8088" |
|
381 |
+ android:textSize="14sp" /> |
|
382 |
+ |
|
383 |
+ <ToggleButton |
|
384 |
+ android:id="@+id/toggle_upload_lock" |
|
385 |
+ android:layout_width="33dp" |
|
386 |
+ android:layout_height="25dp" |
|
387 |
+ android:layout_marginRight="12dp" |
|
388 |
+ android:layout_gravity="center_vertical" |
|
389 |
+ android:background="@drawable/toggle_button_selector" |
|
390 |
+ android:checked="true" |
|
391 |
+ android:gravity="center" |
|
392 |
+ android:textColor="@color/white" |
|
393 |
+ android:textOff="@null" |
|
394 |
+ android:textOn="@null" /> |
|
395 |
+ |
|
396 |
+ </LinearLayout> |
|
397 |
+ |
|
398 |
+ |
|
363 | 399 |
</LinearLayout> |
364 | 400 |
|
365 | 401 |
|
@@ -148,4 +148,7 @@ |
||
148 | 148 |
<string name="scan_login_qr_error">扫描授权码失败</string> |
149 | 149 |
|
150 | 150 |
<string name="logout_user">退出登录</string> |
151 |
+ |
|
152 |
+ <string name="upload_in_mobile_network">运营商网络下自动上传</string> |
|
153 |
+ |
|
151 | 154 |
</resources> |